#include<sys/types.h>
#include<sys/wait.h>
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>

int main()
{
//	printf("程序开始\n");
//	execl("/usr/bin/ls", "ls", "-a", "-l", NULL);
//	printf("程序结束\n");
	pid_t id = fork();
	int status = 0;
	if(id == 0)
	{
		printf("%d\n", getpid());
		int cnt = 5;
		while(cnt--)
		{
			printf("i am child process\n");
		}
		sleep(5);
		exit(EXIT_SUCCESS);
	}

	pid_t terminated_pid = waitpid(id, &status, 0);
	if (WIFEXITED(status)) {
            printf("子进程 %d 正常退出，退出码: %d\n", terminated_pid, WEXITSTATUS(status));
	}
	return 0;
}
